package huahua.microservicesimpleconsumermovie.controller;

import huahua.microservicesimpleconsumermovie.remote.UserRemote;
import huahua.microservicesimpleconsumermovie.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhanghuadi
 * @date: 2018/5/4 0004
 * @description: movie Controller层
 */
@RestController
public class MovieController {

    //需要在启动类上new 一个RestTempte
//    @Autowired
//    private RestTemplate restTemplate;

    @Autowired
    private UserRemote userRemote;

    @GetMapping("/movie/{id}")
    public User findById(@PathVariable("id") Long id){
        //服务IP与端口是会变的，所以该架构存在问题，需要引入注册中心
//        return restTemplate.getForObject();
        return userRemote.user(id);
    }
}
